Component({
  properties: {
    categoryId: Number
  },
  data: {
    fairyDetailList: []
  },
  methods: {
    openFairyDetail(e: any) {
      wx.navigateTo({
        url: `/pages/fairy-detail/fairy-detail?id=${e.target.dataset.id}`,
      })
    },
    fairyDetailListData() {

      wx.request({
        url:'https://wxapi.db101.cn/v1/fairy/detail/list',
        method: 'POST',
        data: {
          // @ts-ignore
          "categoryId": this.data.categoryId
        },
        header: {
          'content-type': 'application/json' // 默认值
        },
        success: (res) => {
          // @ts-ignore
          this.setData( {fairyDetailList: res.data})
        }
      })
    }
  },
  lifetimes: {
    attached: function() {
      // @ts-ignore
      // 在组件实例进入页面节点树时执行
      // @ts-ignore
      this.fairyDetailListData();
    },
    detached: function() {
      // 在组件实例被从页面节点树移除时执行
    },
  }
})
